<script setup>
import { ref, computed } from "vue"

const background = ref('')

const result = computed(() => {
    return {
        backgroundColor: background.value,
        color: "#fff",
        padding: "10px"
    }
})

</script>

<template>
    <input v-model="background" placeholder="输入背景颜色（#ff0000）" />
    <div :style="result">这是一个动态背景颜色的盒子</div>
</template>